package com.example.a22310.myapplication.Activity;
//红色的R解决不了
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.example.a22310.myapplication.Beans.Coach;
import com.example.a22310.myapplication.ViewModel.Attention.AddAttentionViewModel;
import com.example.a22310.myapplication.ViewModel.Master.MasterDetailViewModel;
import com.example.a22310.myapplication.databinding.ActivityMasterDetailBinding;
import com.squareup.picasso.Picasso;

//大师详情
public class MasterDetail extends AppCompatActivity {
    private ActivityMasterDetailBinding binding;
    private Coach.ClubcoachlistBean clubcoachlistBean;
    private String FILENAME = "yuejian'data";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,R.layout.activity_master_detail);
        initialize();

    }
    private void initialize(){
        Intent intent = getIntent();
        clubcoachlistBean = (Coach.ClubcoachlistBean)intent.getSerializableExtra("coach");
        String str =  clubcoachlistBean.getMaster_picture().substring(52, clubcoachlistBean.getMaster_picture().length());
        Picasso.with(this).load(str).into(binding.activityPicture);
        binding.setDetail(clubcoachlistBean);
        String strr =  clubcoachlistBean.getMaster_picture().substring(104,clubcoachlistBean.getMaster_picture().length());
        new MasterDetailViewModel(this,binding,clubcoachlistBean.getClub_id(),clubcoachlistBean.getMaster_name());
        new AddAttentionViewModel(this,binding,getUserid(),clubcoachlistBean.getMaster_id(),clubcoachlistBean.getMaster_name(),
                strr,1);
    }


    private int  getUserid(){
        int newsNumber;
        SharedPreferences sharedPreferences = getSharedPreferences(FILENAME, Context.MODE_PRIVATE);
        newsNumber = sharedPreferences.getInt("userId",0);
        return newsNumber;
    }
}
